{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#!/usr/bin/env python\n",
    "# coding: utf-8\n",
    "\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import random\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "\n",
    "def get_data():\n",
    "    data = pd.read_csv(\"/kaggle/input/train-cnn/p2pData.txt\", sep=\" \", header=None)\n",
    "    label = pd.read_csv(\"/kaggle/input/train-cnn/p2pLabel.txt\", sep=\" \", header=None)\n",
    "    data_columns = data.shape[1]\n",
    "\n",
    "    for i in range(0, data_columns):\n",
    "        if data[i][0] != data[i][0]:\n",
    "            del data[i]\n",
    "\n",
    "    data_columns = data.shape[1]\n",
    "    data.columns = np.arange(0, data_columns)\n",
    "\n",
    "    return data, label\n",
    "\n",
    "\n",
    "def generateSampleList(number):\n",
    "    n_samples = number\n",
    "    sample_list = []\n",
    "    for i in range(0, n_samples // 10):\n",
    "        s = random.randint(0, n_samples)\n",
    "        if s not in sample_list:\n",
    "            sample_list.append(s)\n",
    "\n",
    "    return sample_list\n",
    "\n",
    "\n",
    "data, label = get_data()\n",
    "sampleList = generateSampleList(data.shape[0])\n",
    "data = data.loc[sampleList]\n",
    "label = label.loc[sampleList]\n",
    "scaler = StandardScaler()\n",
    "data = scaler.fit_transform(data)\n",
    "\n",
    "data = np.array(data)\n",
    "label = np.array(label)\n",
    "label = np.reshape(label, label.shape[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(108665, 29)\n"
     ]
    }
   ],
   "source": [
    "from sklearn.feature_selection import VarianceThreshold\n",
    "X1 = data\n",
    "sel = VarianceThreshold(threshold=(.8 * (1 - .8)))\n",
    "X1=sel.fit_transform(X1)\n",
    "print(X1.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Optimal number of features: 20\n",
      "The feature ranking: [ 1  1  1  1  1  1  1  1  1  4  1  1  1  1  2  1  9  6  1  7  8 10  1  5\n",
      "  3  1  1  1  1]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEbCAYAAAArhqjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3XmcHFW99/HPdyb7RhKSIGQHwyLIIsOOCApcQAVRQSIqoo+4ISgXHvFeryxeHvddrhqVxQURETFgNCCrIMsk7EluIGRjApJAJvskmeX3/FHVSWeYma4Z0ullvu/Xq19dVX2q+1fdM3266pzzO4oIzMzMulJT6gDMzKz8ubIwM7OCXFmYmVlBrizMzKwgVxZmZlaQKwszMyvIlYWZmRXUJ0shSWOAo4DdgCbgGWBWRLQVMTYzMysT6mpQnqTjgEuBkcDjwHJgALAnsAdwM/CdiFhT/FDNzKxUClUW3wJ+FBFLO3isD/AuoDYi/li8EM3MrNS6rCzMzMwgYwO3pAslDVPil5Iek3RisYMzM7PykLU31MfSdokTgdHAucDXixaVmZmVlayVhdL7U4BrI+LJvG1mZlblslYWsyXdQVJZzJQ0FHC3WTOzXiJTA7ekGuBAYGFErJK0MzA2Ip4qdoBmZlZ6mQblRUSbpJeBN6VdZs3MrBfJOoL7G8AHgLlAa7o5gPuLFJeZmZWRrJeh5gP7R8Sm4odkZmblJmsD90KgbzEDMTOz8pW1/WED8ISku4AtZxcRcUFRojIzs7KStbKYnt7MzKwXypwbSlI/kmyzAPMjorloUZmZWVnJ2sB9LHA9sJhk5PZ44JyIcG8oM7NeIGtlMRv4YETMT9f3BH4XEQcXOT4zMysDWXtD9c1VFAAR8SzuHWVm1mtkbeCeJemXwK/T9b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ZLr7Tk/J/mCfpTkOnZnv/q7Mp/kS/2vwKciYiPwC2Au8JikZ4CfUeCMOb3k9SWSVM1PAo9FRHfTal8A1KWNvXOBT6Xbvwl8TdKDJNk+c+4huWz1hKQPkMydMFLJLGafJpk3vqNYV5BUOr+T9BRJ5bE3yZfz7em2++igUwHw+bTh/EmSS4J/jYg7SNpbHpL0NMn0mvmVGJ2ViYg5wFXAfelz5tJ53whckjai70FSEXw8LTOHrdMaX0gyYVc9SaVqFSTToDwzM+vdfGZhZmYFubIwM7OCXFmYmVlBrizMzKwgVxZmZlaQKwszMyvIlYWZmRXkysLMzAr6//CIsXnKtC/kAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from sklearn.svm import SVC\n",
    "from sklearn.model_selection import StratifiedKFold\n",
    "from sklearn.feature_selection import RFECV\n",
    "\n",
    "# Create the RFE object and compute a cross-validated score.\n",
    "svc = SVC(kernel=\"linear\")\n",
    "# The \"accuracy\" scoring is proportional to the number of correct\n",
    "# classifications\n",
    "rfecv = RFECV(estimator=svc, step=1, cv=StratifiedKFold(2), scoring='accuracy')\n",
    "rfecv.fit(X1, label)\n",
    "\n",
    "print(\"Optimal number of features:\",rfecv.n_features_)\n",
    "print(\"The feature ranking:\",rfecv.ranking_)\n",
    "\n",
    "# Plot number of features VS. cross-validation scores\n",
    "plt.figure()\n",
    "plt.xlabel(\"Number of features selected\")\n",
    "plt.ylabel(\"Cross validation score (nb of correct classifications)\")\n",
    "plt.plot(range(1, len(rfecv.grid_scores_) + 1), rfecv.grid_scores_)\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
